package com.jisf.driver.auth;

import com.jisf.driver.response.Result;
import com.jisf.driver.response.ResultCode;
import org.springframework.security.web.session.InvalidSessionStrategy;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Classname MyInvalidSessionStrategy
 * @Description TODO 会话超时管理
 * @Date 2022/4/4 23:18
 * @Created by jisf：【429627912@qq.com】
 */
@Component
public class MyInvalidSessionStrategy extends JsonAuthentication implements InvalidSessionStrategy {
    @Override
    public void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        Result result = Result.error(ResultCode.USER_SESSION_INVALID);
        this.WriteJSON(request, response, result);
    }
}
